import * as vscode from 'vscode'
import { createWebViewDebugger } from '../../utils/debugLogger'
import { generateRecordListHtml } from './recordListTemplate'
import { RecordListConfig, RecordListItem } from './types'

export class RecordListRenderer {
  constructor(private extensionUri: vscode.Uri) {}

  generateHtml(webview: vscode.Webview): string {
    const { showDebug, debugHtml, debugStyles, debugScript } = createWebViewDebugger('debug', 'WebView 启动中...')
    console.log('当前调试模式状态:', showDebug)

    // Get path to iconfont.css
    const iconFontCss = webview.asWebviewUri(vscode.Uri.joinPath(this.extensionUri, 'resources', 'iconfont', 'iconfont.css'))

    const config: RecordListConfig = {
      showDebugInfo: showDebug,
      iconFontCssPath: iconFontCss.toString()
    }

    return generateRecordListHtml(config, debugHtml, debugStyles, debugScript)
  }
}
